﻿using System;
using Glue;
using Xunit;

namespace GlueTests.MapperVerificationTests
{
    public class When_mapping_between_guids
    {
        private readonly Mapping<DomainThing, GuiThing> mapping;


        public class DomainThing
        {
            public Guid Id { get; set; }
        }

        public class GuiThing
        {
            public Guid Id { get; set; }
        }
        
        public When_mapping_between_guids()
        {
            mapping = new Mapping<DomainThing, GuiThing>();
            mapping.AutoRelateEqualNames();
        }

        [Fact]
        public void Should_map_value_of_guid()
        {
            Guid guid = Guid.NewGuid();
            var guiObject = mapping.Map(new DomainThing {Id = guid});
            Assert.Equal(guid, guiObject.Id);
        }

        [Fact]
        public void Should_verify_relations_mapping_towards_right()
        {
            mapping.GetRelationsVerification().AssertAllPropertiesRelated<GuiThing>();
        }

        [Fact]
        public void Should_verify_relations_mapping_towards_left()
        {
            mapping.GetRelationsVerification().AssertAllPropertiesRelated<DomainThing>();
        }

        [Fact]
        public void Should_verify_mapping_towards_right()
        {
            mapping.GetMapperVerification().AssertMapsCorrectlyTowards(new GuiThing());
        }

        [Fact]
        public void Should_verify_mapping_towards_left()
        {
            mapping.GetMapperVerification().AssertMapsCorrectlyTowards(new DomainThing());
        }
    }
}
